export interface R<T> {
    code: number;
    msg?: string;
    data?: T;
}

export interface SelfEventListener {
    time: any[],
    listener: Listen[],
    interval: any[]
}

export interface Listen {
    event: keyof WindowEventMap | keyof DocumentEventMap,
    func: EventListenerOrEventListenerObject,
    userCapture?: Document | Window | Element
}

/**
 * 防抖函数
 * @param func 需要执行的函数
 * @param time 延迟时间
 */
export function debounce(func: Function, time: number): any {
    let result: any;
    let timer: any;
    return function (...args: any[]): any {
        if (timer) {
            clearTimeout(timer);
        }
        timer = setTimeout(function () {
            result = func.apply(this, args);
        }, time);
        return result;
    };
}

/**
 * 分页查询参数
 */
export interface Page {
    currentPage: number;

    pageSize: number;
}

/**
 * 分页参数
 */
export interface PageParams {
    current: number;

    size: number;

    total: number;
}

/**
 * 分页返回数据
 */
export interface PageResult<T> {
    records: T[];
    total: number;
    size: number;
    current: number;
    pages: number;
}

/**
 * 字典
 */
export interface Dict {
    code: number;
    value: string;
    type: string;
    desc?: string;
}

export const quality = ["aqi", "pm25", "pm10", "so2", "no2", "co", "o3"]

